# -*- coding: utf-8 -*-
"""
 @Time    : 2021/2/2 下午5:52
 @Author  : tgy
 
"""
import json


class JsonUtils:
    ...

    @staticmethod
    def serialize_instance(instance):

        res = {}
        if not instance:
            return res
        res['__classname__'] = type(instance).__name__
        res.update(vars(instance))
        return res

    @staticmethod
    def unserialize_instance(dic, cla):
        ...
        if not cla:
            return dic
        # 下面只创建内存，不调用 __init__ 初始化
        obj = cla.__new__(cla)
        for key, val in dic.items():
            ...
            if key.startswith('__'):
                continue

            setattr(obj, key, val)
        return obj


if __name__ == '__main__':
    ...
